package com.wcity.manage.web.business;

import com.wcity.manage.common.context.Constants;
import com.wcity.manage.common.enums.Code;
import com.wcity.manage.common.exception.CustomException;
import com.wcity.manage.common.utils.StringUtil;
import com.wcity.manage.dao.dal.model.PageModel;
import com.wcity.manage.dao.model.business.BusinessInfo;
import com.wcity.manage.service.business.BusinessInfoService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Created by Zm on 2017/3/20.
 */
@Controller
@RequestMapping("v1")
public class BusinessInfoAct {

    @Resource private BusinessInfoService businessInfoService;

    @RequestMapping("business_list")
    @ResponseBody
    public Object businessList(PageModel pageModel,BusinessInfo businessInfo){

        if(StringUtil.isBlank(businessInfo.getCity())||StringUtil.isBlank(businessInfo.getLng()+"")||StringUtil.isBlank(businessInfo.getLat()+"")
                ||StringUtil.isBlank(businessInfo.getType()))
            throw new CustomException( Constants.PARAMETER_ERROR, Code.ERROR );

        pageModel.setParams(businessInfo);
        Map<String,Object> map = businessInfoService.findListPage(pageModel);

        return map;
    }
}
